using System;
using System.Windows;

namespace LaplaceMeshDeformer
{
    /// <summary>
    /// 平滑处理对话框
    /// </summary>
    public partial class SmoothWindow : Window
    {
        public int Iterations { get; private set; }
        public double Lambda { get; private set; }

        public SmoothWindow()
        {
            InitializeComponent();
            
            // 默认值
            Iterations = 10;
            Lambda = 0.5;
            
            // 设置输入框默认值
            txtIterations.Text = "10";
            txtLambda.Text = "0.5";
        }

        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            // 验证输入
            if (!int.TryParse(txtIterations.Text, out int iterations) ||
                !double.TryParse(txtLambda.Text, out double lambda))
            {
                MessageBox.Show("请输入有效的数值！", "输入错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            
            if (iterations <= 0)
            {
                MessageBox.Show("迭代次数必须大于0！", "输入错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            
            if (lambda <= 0 || lambda > 1)
            {
                MessageBox.Show("平滑强度必须在0-1之间！", "输入错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            
            Iterations = iterations;
            Lambda = lambda;
            
            DialogResult = true;
            Close();
        }
    }
} 